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
0fd3302e
Commit
0fd3302e
authored
Jul 21, 2015
by
Matt Perry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed AnimatedType to AnimatedValue
parent
f3e07210
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
140 additions
and
127 deletions
+140
-127
BUILD.gn
packages/flutter/BUILD.gn
+1
-0
stock_home.dart
packages/flutter/example/stocks/lib/stock_home.dart
+3
-3
card_collection.dart
packages/flutter/example/widgets/card_collection.dart
+2
-1
animated_value.dart
packages/flutter/lib/animation/animated_value.dart
+79
-0
animation_performance.dart
packages/flutter/lib/animation/animation_performance.dart
+3
-66
flex.dart
packages/flutter/lib/rendering/flex.dart
+1
-2
animated_container.dart
packages/flutter/lib/widgets/animated_container.dart
+11
-10
animation_builder.dart
packages/flutter/lib/widgets/animation_builder.dart
+7
-17
dismissable.dart
packages/flutter/lib/widgets/dismissable.dart
+6
-5
drawer.dart
packages/flutter/lib/widgets/drawer.dart
+4
-4
ink_well.dart
packages/flutter/lib/widgets/ink_well.dart
+3
-2
navigator.dart
packages/flutter/lib/widgets/navigator.dart
+5
-4
popup_menu.dart
packages/flutter/lib/widgets/popup_menu.dart
+11
-10
toggleable.dart
packages/flutter/lib/widgets/toggleable.dart
+4
-3
No files found.
packages/flutter/BUILD.gn
View file @
0fd3302e
...
...
@@ -9,6 +9,7 @@ dart_pkg("sky") {
"CHANGELOG.md",
"bin/init.dart",
"lib/animation/animated_simulation.dart",
"lib/animation/animated_value.dart",
"lib/animation/animation_performance.dart",
"lib/animation/curves.dart",
"lib/animation/forces.dart",
...
...
packages/flutter/example/stocks/lib/stock_home.dart
View file @
0fd3302e
...
...
@@ -3,7 +3,7 @@
// found in the LICENSE file.
import
'package:sky/editing/input.dart'
;
import
'package:sky/animation/animat
ion_performanc
e.dart'
;
import
'package:sky/animation/animat
ed_valu
e.dart'
;
import
'package:sky/widgets/animated_component.dart'
;
import
'package:sky/widgets/animation_builder.dart'
;
import
'package:sky/theme/colors.dart'
as
colors
;
...
...
@@ -280,10 +280,10 @@ class StockHome extends AnimatedComponent {
void
_handleStockPurchased
()
{
setState
(()
{
_snackbarTransform
=
new
AnimationBuilder
()
..
position
=
new
Animated
Typ
e
<
Point
>(
const
Point
(
0.0
,
45.0
),
end:
Point
.
origin
);
..
position
=
new
Animated
Valu
e
<
Point
>(
const
Point
(
0.0
,
45.0
),
end:
Point
.
origin
);
var
performance
=
_snackbarTransform
.
createPerformance
(
[
_snackbarTransform
.
position
],
duration:
_kSnackbarSlideDuration
);
watch
(
performance
);
watch
(
performance
);
// TODO(mpcomplete): need to unwatch
performance
.
play
();
});
}
...
...
packages/flutter/example/widgets/card_collection.dart
View file @
0fd3302e
...
...
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:sky/animation/animated_value.dart'
;
import
'package:sky/animation/animation_performance.dart'
;
import
'package:sky/animation/curves.dart'
;
import
'package:sky/base/lerp.dart'
;
...
...
@@ -100,7 +101,7 @@ class CardCollectionApp extends App {
assert
(
card
.
performance
==
null
);
card
.
performance
=
new
AnimationPerformance
()
..
duration
=
const
Duration
(
milliseconds:
300
)
..
variable
=
new
Animated
Typ
e
<
double
>(
..
variable
=
new
Animated
Valu
e
<
double
>(
card
.
height
+
kCardMargins
.
top
+
kCardMargins
.
bottom
,
end:
0.0
,
curve:
ease
,
...
...
packages/flutter/lib/animation/animated_value.dart
0 → 100644
View file @
0fd3302e
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
"dart:sky"
;
import
'package:sky/animation/curves.dart'
;
import
'package:sky/base/lerp.dart'
;
abstract
class
AnimatedVariable
{
void
setProgress
(
double
t
);
String
toString
();
}
class
Interval
{
final
double
start
;
final
double
end
;
double
adjustTime
(
double
t
)
{
return
((
t
-
start
)
/
(
end
-
start
)).
clamp
(
0.0
,
1.0
);
}
Interval
(
this
.
start
,
this
.
end
)
{
assert
(
start
>=
0.0
);
assert
(
start
<=
1.0
);
assert
(
end
>=
0.0
);
assert
(
end
<=
1.0
);
}
}
class
AnimatedValue
<
T
extends
dynamic
>
extends
AnimatedVariable
{
AnimatedValue
(
this
.
begin
,
{
this
.
end
,
this
.
interval
,
this
.
curve
:
linear
})
{
value
=
begin
;
}
T
value
;
T
begin
;
T
end
;
Interval
interval
;
Curve
curve
;
void
setProgress
(
double
t
)
{
if
(
end
!=
null
)
{
double
adjustedTime
=
interval
==
null
?
t
:
interval
.
adjustTime
(
t
);
if
(
adjustedTime
==
1.0
)
{
value
=
end
;
}
else
{
// TODO(mpcomplete): Reverse the timeline and curve.
value
=
begin
+
(
end
-
begin
)
*
curve
.
transform
(
adjustedTime
);
}
}
}
String
toString
()
=>
'AnimatedValue(begin=
$begin
, end=
$end
, value=
$value
)'
;
}
class
AnimatedList
extends
AnimatedVariable
{
List
<
AnimatedVariable
>
variables
;
Interval
interval
;
AnimatedList
(
this
.
variables
,
{
this
.
interval
});
void
setProgress
(
double
t
)
{
double
adjustedTime
=
interval
==
null
?
t
:
interval
.
adjustTime
(
t
);
for
(
AnimatedVariable
variable
in
variables
)
variable
.
setProgress
(
adjustedTime
);
}
String
toString
()
=>
'AnimatedList([
$variables
])'
;
}
class
AnimatedColor
extends
AnimatedValue
<
Color
>
{
AnimatedColor
(
Color
begin
,
{
Color
end
,
Curve
curve:
linear
})
:
super
(
begin
,
end:
end
,
curve:
curve
);
void
setProgress
(
double
t
)
{
value
=
lerpColor
(
begin
,
end
,
t
);
}
}
packages/flutter/lib/animation/animation_performance.dart
View file @
0fd3302e
...
...
@@ -4,71 +4,9 @@
import
'dart:async'
;
import
'package:sky/animation/timeline.dart'
;
import
'package:sky/animation/curves.dart'
;
import
'package:sky/animation/animated_value.dart'
;
import
'package:sky/animation/forces.dart'
;
abstract
class
AnimatedVariable
{
void
setFraction
(
double
t
);
String
toString
();
}
class
Interval
{
final
double
start
;
final
double
end
;
double
adjustTime
(
double
t
)
{
return
((
t
-
start
)
/
(
end
-
start
)).
clamp
(
0.0
,
1.0
);
}
Interval
(
this
.
start
,
this
.
end
)
{
assert
(
start
>=
0.0
);
assert
(
start
<=
1.0
);
assert
(
end
>=
0.0
);
assert
(
end
<=
1.0
);
}
}
class
AnimatedType
<
T
extends
dynamic
>
extends
AnimatedVariable
{
AnimatedType
(
this
.
begin
,
{
this
.
end
,
this
.
interval
,
this
.
curve
:
linear
})
{
value
=
begin
;
}
T
value
;
T
begin
;
T
end
;
Interval
interval
;
Curve
curve
;
void
setFraction
(
double
t
)
{
if
(
end
!=
null
)
{
double
adjustedTime
=
interval
==
null
?
t
:
interval
.
adjustTime
(
t
);
if
(
adjustedTime
==
1.0
)
{
value
=
end
;
}
else
{
// TODO(mpcomplete): Reverse the timeline and curve.
value
=
begin
+
(
end
-
begin
)
*
curve
.
transform
(
adjustedTime
);
}
}
}
String
toString
()
=>
'AnimatedType(begin=
$begin
, end=
$end
, value=
$value
)'
;
}
class
AnimatedList
extends
AnimatedVariable
{
List
<
AnimatedVariable
>
variables
;
Interval
interval
;
AnimatedList
(
this
.
variables
,
{
this
.
interval
});
void
setFraction
(
double
t
)
{
double
adjustedTime
=
interval
==
null
?
t
:
interval
.
adjustTime
(
t
);
for
(
AnimatedVariable
variable
in
variables
)
variable
.
setFraction
(
adjustedTime
);
}
String
toString
()
=>
'AnimatedList([
$variables
])'
;
}
import
'package:sky/animation/timeline.dart'
;
// This class manages a "performance" - a collection of values that change
// based on a timeline. For example, a performance may handle an animation
...
...
@@ -82,7 +20,6 @@ class AnimationPerformance {
_timeline
=
new
Timeline
(
_tick
);
}
// TODO(mpcomplete): make this a list, or composable somehow.
AnimatedVariable
variable
;
// TODO(mpcomplete): duration should be on a director.
Duration
duration
;
...
...
@@ -142,7 +79,7 @@ class AnimationPerformance {
}
void
_tick
(
double
t
)
{
variable
.
set
Fraction
(
t
);
variable
.
set
Progress
(
t
);
_notifyListeners
();
}
}
packages/flutter/lib/rendering/flex.dart
View file @
0fd3302e
...
...
@@ -83,6 +83,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
}
// Set during layout if overflow occurred on the main axis
TextBaseline
_textBaseline
;
TextBaseline
get
textBaseline
=>
_textBaseline
;
void
set
textBaseline
(
TextBaseline
value
)
{
...
...
@@ -92,8 +93,6 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
}
// Set during layout if overflow occurred on the main axis
double
_overflow
;
void
setupParentData
(
RenderBox
child
)
{
if
(
child
.
parentData
is
!
FlexBoxParentData
)
...
...
packages/flutter/lib/widgets/animated_container.dart
View file @
0fd3302e
...
...
@@ -4,6 +4,7 @@
import
'package:vector_math/vector_math.dart'
;
import
'package:sky/animation/animated_value.dart'
;
import
'package:sky/animation/animation_performance.dart'
;
import
'package:sky/animation/curves.dart'
;
import
'package:sky/base/lerp.dart'
;
...
...
@@ -11,21 +12,21 @@ import 'package:sky/painting/box_painter.dart';
import
'package:sky/widgets/basic.dart'
;
import
'package:sky/widgets/animated_component.dart'
;
class
AnimatedBoxConstraintsValue
extends
Animated
Typ
e
<
BoxConstraints
>
{
class
AnimatedBoxConstraintsValue
extends
Animated
Valu
e
<
BoxConstraints
>
{
AnimatedBoxConstraintsValue
(
BoxConstraints
begin
,
{
BoxConstraints
end
,
Curve
curve:
linear
})
:
super
(
begin
,
end:
end
,
curve:
curve
);
void
set
Fraction
(
double
t
)
{
void
set
Progress
(
double
t
)
{
// TODO(abarth): We should lerp the BoxConstraints.
value
=
end
;
}
}
class
AnimatedBoxDecorationValue
extends
Animated
Typ
e
<
BoxDecoration
>
{
class
AnimatedBoxDecorationValue
extends
Animated
Valu
e
<
BoxDecoration
>
{
AnimatedBoxDecorationValue
(
BoxDecoration
begin
,
{
BoxDecoration
end
,
Curve
curve:
linear
})
:
super
(
begin
,
end:
end
,
curve:
curve
);
void
set
Fraction
(
double
t
)
{
void
set
Progress
(
double
t
)
{
if
(
t
==
1.0
)
{
value
=
end
;
return
;
...
...
@@ -34,11 +35,11 @@ class AnimatedBoxDecorationValue extends AnimatedType<BoxDecoration> {
}
}
class
AnimatedEdgeDimsValue
extends
Animated
Typ
e
<
EdgeDims
>
{
class
AnimatedEdgeDimsValue
extends
Animated
Valu
e
<
EdgeDims
>
{
AnimatedEdgeDimsValue
(
EdgeDims
begin
,
{
EdgeDims
end
,
Curve
curve:
linear
})
:
super
(
begin
,
end:
end
,
curve:
curve
);
void
set
Fraction
(
double
t
)
{
void
set
Progress
(
double
t
)
{
if
(
t
==
1.0
)
{
value
=
end
;
return
;
...
...
@@ -54,7 +55,7 @@ class AnimatedEdgeDimsValue extends AnimatedType<EdgeDims> {
class
ImplicitlyAnimatedValue
<
T
>
{
final
AnimationPerformance
performance
=
new
AnimationPerformance
();
final
Animated
Typ
e
<
T
>
_variable
;
final
Animated
Valu
e
<
T
>
_variable
;
ImplicitlyAnimatedValue
(
this
.
_variable
,
Duration
duration
)
{
performance
...
...
@@ -168,21 +169,21 @@ class AnimatedContainer extends AnimatedComponent {
void
_updateTransform
()
{
_updateField
(
transform
,
_transform
,
()
{
_transform
=
new
ImplicitlyAnimatedValue
<
Matrix4
>(
new
Animated
Typ
e
<
Matrix4
>(
transform
),
duration
);
_transform
=
new
ImplicitlyAnimatedValue
<
Matrix4
>(
new
Animated
Valu
e
<
Matrix4
>(
transform
),
duration
);
watch
(
_transform
.
performance
);
});
}
void
_updateWidth
()
{
_updateField
(
width
,
_width
,
()
{
_width
=
new
ImplicitlyAnimatedValue
<
double
>(
new
Animated
Typ
e
<
double
>(
width
),
duration
);
_width
=
new
ImplicitlyAnimatedValue
<
double
>(
new
Animated
Valu
e
<
double
>(
width
),
duration
);
watch
(
_width
.
performance
);
});
}
void
_updateHeight
()
{
_updateField
(
height
,
_height
,
()
{
_height
=
new
ImplicitlyAnimatedValue
<
double
>(
new
Animated
Typ
e
<
double
>(
height
),
duration
);
_height
=
new
ImplicitlyAnimatedValue
<
double
>(
new
Animated
Valu
e
<
double
>(
height
),
duration
);
watch
(
_height
.
performance
);
});
}
...
...
packages/flutter/lib/widgets/animation_builder.dart
View file @
0fd3302e
...
...
@@ -4,9 +4,8 @@
import
'package:vector_math/vector_math.dart'
;
import
'package:sky/animation/animated_value.dart'
;
import
'package:sky/animation/animation_performance.dart'
;
import
'package:sky/animation/curves.dart'
;
import
'package:sky/base/lerp.dart'
;
import
'package:sky/painting/box_painter.dart'
;
import
'package:sky/theme/shadows.dart'
;
import
'package:sky/widgets/basic.dart'
;
...
...
@@ -18,9 +17,9 @@ class AnimationBuilder {
AnimationBuilder
();
Animated
Typ
e
<
double
>
opacity
;
Animated
Typ
e
<
Point
>
position
;
Animated
Typ
e
<
double
>
shadow
;
Animated
Valu
e
<
double
>
opacity
;
Animated
Valu
e
<
Point
>
position
;
Animated
Valu
e
<
double
>
shadow
;
AnimatedColor
backgroundColor
;
// These don't animate, but are used to build the AnimationBuilder anyway.
...
...
@@ -30,7 +29,7 @@ class AnimationBuilder {
Map
<
AnimatedVariable
,
AnimationPerformance
>
_variableToPerformance
=
new
Map
<
AnimatedVariable
,
AnimationPerformance
>();
AnimationPerformance
createPerformance
(
List
<
Animated
Typ
e
>
variables
,
AnimationPerformance
createPerformance
(
List
<
Animated
Valu
e
>
variables
,
{
Duration
duration
})
{
AnimationPerformance
performance
=
new
AnimationPerformance
()
..
duration
=
duration
...
...
@@ -67,7 +66,7 @@ class AnimationBuilder {
}
void
updateFields
({
Animated
Typ
e
<
double
>
shadow
,
Animated
Valu
e
<
double
>
shadow
,
AnimatedColor
backgroundColor
,
double
borderRadius
,
Shape
shape
...
...
@@ -78,7 +77,7 @@ class AnimationBuilder {
this
.
shape
=
shape
;
}
void
_updateField
(
Animated
Type
variable
,
AnimatedTyp
e
sourceVariable
)
{
void
_updateField
(
Animated
Value
variable
,
AnimatedValu
e
sourceVariable
)
{
if
(
variable
==
null
)
return
;
// TODO(mpcomplete): Should we handle transition from null?
...
...
@@ -101,15 +100,6 @@ class AnimationBuilder {
}
}
class
AnimatedColor
extends
AnimatedType
<
Color
>
{
AnimatedColor
(
Color
begin
,
{
Color
end
,
Curve
curve:
linear
})
:
super
(
begin
,
end:
end
,
curve:
curve
);
void
setFraction
(
double
t
)
{
value
=
lerpColor
(
begin
,
end
,
t
);
}
}
List
<
BoxShadow
>
_computeShadow
(
double
level
)
{
if
(
level
<
1.0
)
// shadows[1] is the first shadow
return
null
;
...
...
packages/flutter/lib/widgets/dismissable.dart
View file @
0fd3302e
...
...
@@ -4,6 +4,7 @@
import
'dart:sky'
as
sky
;
import
'package:sky/animation/animated_value.dart'
;
import
'package:sky/animation/animation_performance.dart'
;
import
'package:sky/widgets/animated_component.dart'
;
import
'package:sky/widgets/basic.dart'
;
...
...
@@ -13,7 +14,7 @@ import 'package:vector_math/vector_math.dart';
const
Duration
_kCardDismissFadeout
=
const
Duration
(
milliseconds:
200
);
const
double
_kMinFlingVelocity
=
700.0
;
const
double
_kMinFlingVelocityDelta
=
400.0
;
const
double
_kFlingVelocityScale
=
1.0
/
300.0
;
const
double
_kFlingVelocityScale
=
1.0
/
300.0
;
const
double
_kDismissCardThreshold
=
0.6
;
typedef
void
DismissedCallback
(
);
...
...
@@ -30,8 +31,8 @@ class Dismissable extends AnimatedComponent {
Widget
child
;
DismissedCallback
onDismissed
;
Animated
Typ
e
<
Point
>
_position
;
Animated
Typ
e
<
double
>
_opacity
;
Animated
Valu
e
<
Point
>
_position
;
Animated
Valu
e
<
double
>
_opacity
;
AnimationPerformance
_performance
;
double
_width
;
...
...
@@ -39,8 +40,8 @@ class Dismissable extends AnimatedComponent {
bool
_dragUnderway
=
false
;
void
initState
()
{
_position
=
new
Animated
Typ
e
<
Point
>(
Point
.
origin
);
_opacity
=
new
Animated
Typ
e
<
double
>(
1.0
,
end:
0.0
);
_position
=
new
Animated
Valu
e
<
Point
>(
Point
.
origin
);
_opacity
=
new
Animated
Valu
e
<
double
>(
1.0
,
end:
0.0
);
_performance
=
new
AnimationPerformance
()
..
duration
=
_kCardDismissFadeout
..
variable
=
new
AnimatedList
([
_position
,
_opacity
])
...
...
packages/flutter/lib/widgets/drawer.dart
View file @
0fd3302e
...
...
@@ -4,11 +4,11 @@
import
'dart:sky'
as
sky
;
import
'package:sky/animation/animated_value.dart'
;
import
'package:sky/animation/animation_performance.dart'
;
import
'package:sky/theme/shadows.dart'
;
import
'package:sky/theme/colors.dart'
as
colors
;
import
'package:sky/widgets/animated_component.dart'
;
import
'package:sky/widgets/animation_builder.dart'
;
import
'package:sky/widgets/basic.dart'
;
import
'package:sky/widgets/navigator.dart'
;
import
'package:sky/widgets/scrollable_viewport.dart'
;
...
...
@@ -30,7 +30,7 @@ import 'package:vector_math/vector_math.dart';
const
double
_kWidth
=
304.0
;
const
double
_kMinFlingVelocity
=
365.0
;
const
double
_kFlingVelocityScale
=
1.0
/
300.0
;
const
double
_kFlingVelocityScale
=
1.0
/
300.0
;
const
Duration
_kBaseSettleDuration
=
const
Duration
(
milliseconds:
246
);
const
Point
_kOpenPosition
=
Point
.
origin
;
const
Point
_kClosedPosition
=
const
Point
(-
_kWidth
,
0.0
);
...
...
@@ -60,12 +60,12 @@ class Drawer extends AnimatedComponent {
DrawerStatusChangedCallback
onStatusChanged
;
Navigator
navigator
;
Animated
Typ
e
<
Point
>
_position
;
Animated
Valu
e
<
Point
>
_position
;
AnimatedColor
_maskColor
;
AnimationPerformance
_performance
;
void
initState
()
{
_position
=
new
Animated
Typ
e
<
Point
>(
_kClosedPosition
,
end:
_kOpenPosition
);
_position
=
new
Animated
Valu
e
<
Point
>(
_kClosedPosition
,
end:
_kOpenPosition
);
_maskColor
=
new
AnimatedColor
(
colors
.
transparent
,
end:
const
Color
(
0x7F000000
));
_performance
=
new
AnimationPerformance
()
..
duration
=
_kBaseSettleDuration
...
...
packages/flutter/lib/widgets/ink_well.dart
View file @
0fd3302e
...
...
@@ -5,6 +5,7 @@
import
'dart:math'
as
math
;
import
'dart:sky'
as
sky
;
import
'package:sky/animation/animated_value.dart'
;
import
'package:sky/animation/animation_performance.dart'
;
import
'package:sky/animation/curves.dart'
;
import
'package:sky/rendering/box.dart'
;
...
...
@@ -29,7 +30,7 @@ double _getSplashTargetSize(Size bounds, Point position) {
class
InkSplash
{
InkSplash
(
this
.
pointer
,
this
.
position
,
this
.
well
)
{
_targetRadius
=
_getSplashTargetSize
(
well
.
size
,
position
);
_radius
=
new
Animated
Typ
e
<
double
>(
_radius
=
new
Animated
Valu
e
<
double
>(
_kSplashInitialSize
,
end:
_targetRadius
,
curve:
easeOut
);
_performance
=
new
AnimationPerformance
()
...
...
@@ -45,7 +46,7 @@ class InkSplash {
double
_targetRadius
;
double
_pinnedRadius
;
Animated
Typ
e
<
double
>
_radius
;
Animated
Valu
e
<
double
>
_radius
;
AnimationPerformance
_performance
;
void
_updateVelocity
(
double
velocity
)
{
...
...
packages/flutter/lib/widgets/navigator.dart
View file @
0fd3302e
...
...
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:sky/animation/animated_value.dart'
;
import
'package:sky/animation/animation_performance.dart'
;
import
'package:sky/animation/curves.dart'
;
import
'package:sky/widgets/animated_component.dart'
;
...
...
@@ -59,17 +60,17 @@ class Transition extends AnimatedComponent {
Function
onDismissed
;
Function
onCompleted
;
Animated
Typ
e
<
Point
>
_position
;
Animated
Typ
e
<
double
>
_opacity
;
Animated
Valu
e
<
Point
>
_position
;
Animated
Valu
e
<
double
>
_opacity
;
AnimationPerformance
_performance
;
void
initState
()
{
_position
=
new
Animated
Typ
e
<
Point
>(
_position
=
new
Animated
Valu
e
<
Point
>(
_kTransitionStartPoint
,
end:
Point
.
origin
,
curve:
easeOut
);
_opacity
=
new
Animated
Typ
e
<
double
>(
0.0
,
end:
1.0
)
_opacity
=
new
Animated
Valu
e
<
double
>(
0.0
,
end:
1.0
)
..
curve
=
easeOut
;
_performance
=
new
AnimationPerformance
()
..
duration
=
_kTransitionDuration
...
...
packages/flutter/lib/widgets/popup_menu.dart
View file @
0fd3302e
...
...
@@ -5,6 +5,7 @@
import
'dart:math'
as
math
;
import
'dart:sky'
as
sky
;
import
'package:sky/animation/animated_value.dart'
;
import
'package:sky/animation/animation_performance.dart'
;
import
'package:sky/painting/box_painter.dart'
;
import
'package:sky/theme/colors.dart'
;
...
...
@@ -48,10 +49,10 @@ class PopupMenu extends AnimatedComponent {
int
level
;
Navigator
navigator
;
Animated
Typ
e
<
double
>
_opacity
;
Animated
Typ
e
<
double
>
_width
;
Animated
Typ
e
<
double
>
_height
;
List
<
Animated
Typ
e
<
double
>>
_itemOpacities
;
Animated
Valu
e
<
double
>
_opacity
;
Animated
Valu
e
<
double
>
_width
;
Animated
Valu
e
<
double
>
_height
;
List
<
Animated
Valu
e
<
double
>>
_itemOpacities
;
AnimatedList
_animationList
;
AnimationPerformance
_performance
;
...
...
@@ -88,14 +89,14 @@ class PopupMenu extends AnimatedComponent {
void
_updateAnimationVariables
()
{
double
unit
=
1.0
/
(
items
.
length
+
1.5
);
// 1.0 for the width and 0.5 for the last item's fade.
_opacity
=
new
Animated
Typ
e
<
double
>(
0.0
,
end:
1.0
);
_width
=
new
Animated
Typ
e
<
double
>(
0.0
,
end:
1.0
,
interval:
new
Interval
(
0.0
,
unit
));
_height
=
new
Animated
Typ
e
<
double
>(
0.0
,
end:
1.0
,
interval:
new
Interval
(
0.0
,
unit
*
items
.
length
));
_itemOpacities
=
new
List
<
Animated
Typ
e
<
double
>>();
_opacity
=
new
Animated
Valu
e
<
double
>(
0.0
,
end:
1.0
);
_width
=
new
Animated
Valu
e
<
double
>(
0.0
,
end:
1.0
,
interval:
new
Interval
(
0.0
,
unit
));
_height
=
new
Animated
Valu
e
<
double
>(
0.0
,
end:
1.0
,
interval:
new
Interval
(
0.0
,
unit
*
items
.
length
));
_itemOpacities
=
new
List
<
Animated
Valu
e
<
double
>>();
for
(
int
i
=
0
;
i
<
items
.
length
;
++
i
)
{
double
start
=
(
i
+
1
)
*
unit
;
double
end
=
(
start
+
1.5
*
unit
).
clamp
(
0.0
,
1.0
);
_itemOpacities
.
add
(
new
Animated
Typ
e
<
double
>(
_itemOpacities
.
add
(
new
Animated
Valu
e
<
double
>(
0.0
,
end:
1.0
,
interval:
new
Interval
(
start
,
end
)));
}
List
<
AnimatedVariable
>
variables
=
new
List
<
AnimatedVariable
>()
...
...
@@ -121,7 +122,7 @@ class PopupMenu extends AnimatedComponent {
PopupMenuStatus
status
=
_status
;
if
(
_lastStatus
!=
null
&&
status
!=
_lastStatus
)
{
if
(
status
==
PopupMenuStatus
.
inactive
&&
navigator
!=
null
&&
navigator
!=
null
&&
navigator
.
currentRoute
.
key
==
this
)
navigator
.
pop
();
if
(
onStatusChanged
!=
null
)
...
...
packages/flutter/lib/widgets/toggleable.dart
View file @
0fd3302e
...
...
@@ -4,6 +4,7 @@
import
'dart:sky'
as
sky
;
import
'package:sky/animation/animated_value.dart'
;
import
'package:sky/animation/animation_performance.dart'
;
import
'package:sky/animation/curves.dart'
;
import
'package:sky/widgets/animated_component.dart'
;
...
...
@@ -24,14 +25,14 @@ abstract class Toggleable extends AnimatedComponent {
bool
value
;
ValueChanged
onChanged
;
Animated
Typ
e
<
double
>
_position
;
Animated
Typ
e
<
double
>
get
position
=>
_position
;
Animated
Valu
e
<
double
>
_position
;
Animated
Valu
e
<
double
>
get
position
=>
_position
;
AnimationPerformance
_performance
;
AnimationPerformance
get
performance
=>
_performance
;
void
initState
()
{
_position
=
new
Animated
Typ
e
<
double
>(
0.0
,
end:
1.0
);
_position
=
new
Animated
Valu
e
<
double
>(
0.0
,
end:
1.0
);
_performance
=
new
AnimationPerformance
()
..
variable
=
position
..
duration
=
_kCheckDuration
...
...
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