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
e0df9eca
Commit
e0df9eca
authored
Mar 09, 2016
by
Hans Muller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added SizeTransition
parent
df94a0ea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
19 deletions
+51
-19
dismissable.dart
packages/flutter/lib/src/widgets/dismissable.dart
+13
-18
transitions.dart
packages/flutter/lib/src/widgets/transitions.dart
+38
-1
No files found.
packages/flutter/lib/src/widgets/dismissable.dart
View file @
e0df9eca
...
@@ -7,13 +7,13 @@ import 'transitions.dart';
...
@@ -7,13 +7,13 @@ import 'transitions.dart';
import
'framework.dart'
;
import
'framework.dart'
;
import
'gesture_detector.dart'
;
import
'gesture_detector.dart'
;
const
Duration
_k
Card
DismissDuration
=
const
Duration
(
milliseconds:
200
);
const
Duration
_kDismissDuration
=
const
Duration
(
milliseconds:
200
);
const
Duration
_k
Card
ResizeDuration
=
const
Duration
(
milliseconds:
300
);
const
Duration
_kResizeDuration
=
const
Duration
(
milliseconds:
300
);
const
Curve
_k
Card
ResizeTimeCurve
=
const
Interval
(
0.4
,
1.0
,
curve:
Curves
.
ease
);
const
Curve
_kResizeTimeCurve
=
const
Interval
(
0.4
,
1.0
,
curve:
Curves
.
ease
);
const
double
_kMinFlingVelocity
=
700.0
;
const
double
_kMinFlingVelocity
=
700.0
;
const
double
_kMinFlingVelocityDelta
=
400.0
;
const
double
_kMinFlingVelocityDelta
=
400.0
;
const
double
_kFlingVelocityScale
=
1.0
/
300.0
;
const
double
_kFlingVelocityScale
=
1.0
/
300.0
;
const
double
_kDismiss
Card
Threshold
=
0.4
;
const
double
_kDismissThreshold
=
0.4
;
typedef
void
DismissDirectionCallback
(
DismissDirection
direction
);
typedef
void
DismissDirectionCallback
(
DismissDirection
direction
);
...
@@ -93,7 +93,7 @@ class Dismissable extends StatefulComponent {
...
@@ -93,7 +93,7 @@ class Dismissable extends StatefulComponent {
class
_DismissableState
extends
State
<
Dismissable
>
{
class
_DismissableState
extends
State
<
Dismissable
>
{
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
_moveController
=
new
AnimationController
(
duration:
_k
Card
DismissDuration
)
_moveController
=
new
AnimationController
(
duration:
_kDismissDuration
)
..
addStatusListener
(
_handleDismissStatusChanged
);
..
addStatusListener
(
_handleDismissStatusChanged
);
_updateMoveAnimation
();
_updateMoveAnimation
();
}
}
...
@@ -231,7 +231,7 @@ class _DismissableState extends State<Dismissable> {
...
@@ -231,7 +231,7 @@ class _DismissableState extends State<Dismissable> {
double
flingVelocity
=
_directionIsXAxis
?
velocity
.
pixelsPerSecond
.
dx
:
velocity
.
pixelsPerSecond
.
dy
;
double
flingVelocity
=
_directionIsXAxis
?
velocity
.
pixelsPerSecond
.
dx
:
velocity
.
pixelsPerSecond
.
dy
;
_dragExtent
=
flingVelocity
.
sign
;
_dragExtent
=
flingVelocity
.
sign
;
_moveController
.
fling
(
velocity:
flingVelocity
.
abs
()
*
_kFlingVelocityScale
);
_moveController
.
fling
(
velocity:
flingVelocity
.
abs
()
*
_kFlingVelocityScale
);
}
else
if
(
_moveController
.
value
>
_kDismiss
Card
Threshold
)
{
}
else
if
(
_moveController
.
value
>
_kDismissThreshold
)
{
_moveController
.
forward
();
_moveController
.
forward
();
}
else
{
}
else
{
_moveController
.
reverse
();
_moveController
.
reverse
();
...
@@ -247,16 +247,16 @@ class _DismissableState extends State<Dismissable> {
...
@@ -247,16 +247,16 @@ class _DismissableState extends State<Dismissable> {
assert
(
_moveController
!=
null
);
assert
(
_moveController
!=
null
);
assert
(
_moveController
.
isCompleted
);
assert
(
_moveController
.
isCompleted
);
assert
(
_resizeController
==
null
);
assert
(
_resizeController
==
null
);
_resizeController
=
new
AnimationController
(
duration:
_k
Card
ResizeDuration
)
_resizeController
=
new
AnimationController
(
duration:
_kResizeDuration
)
..
addListener
(
_handleResizeProgressChanged
);
..
addListener
(
_handleResizeProgressChanged
);
_resizeController
.
forward
();
_resizeController
.
forward
();
setState
(()
{
setState
(()
{
_resizeAnimation
=
new
Tween
<
double
>(
_resizeAnimation
=
new
Tween
<
double
>(
begin:
_directionIsXAxis
?
_findSize
().
height
:
_findSize
().
width
,
begin:
1.0
,
end:
0.0
end:
0.0
).
animate
(
new
CurvedAnimation
(
).
animate
(
new
CurvedAnimation
(
parent:
_resizeController
,
parent:
_resizeController
,
curve:
_k
Card
ResizeTimeCurve
curve:
_kResizeTimeCurve
));
));
});
});
}
}
...
@@ -293,15 +293,10 @@ class _DismissableState extends State<Dismissable> {
...
@@ -293,15 +293,10 @@ class _DismissableState extends State<Dismissable> {
return
true
;
return
true
;
});
});
return
new
AnimatedBuilder
(
return
new
SizeTransition
(
animation:
_resizeAnimation
,
sizeFactor:
_resizeAnimation
,
builder:
(
BuildContext
context
,
Widget
child
)
{
axis:
_directionIsXAxis
?
Axis
.
horizontal
:
Axis
.
vertical
,
return
new
SizedBox
(
child:
background
width:
!
_directionIsXAxis
?
_resizeAnimation
.
value
:
null
,
height:
_directionIsXAxis
?
_resizeAnimation
.
value
:
null
,
child:
background
);
}
);
);
}
}
...
...
packages/flutter/lib/src/widgets/transitions.dart
View file @
e0df9eca
...
@@ -108,7 +108,7 @@ class SlideTransition extends AnimatedComponent {
...
@@ -108,7 +108,7 @@ class SlideTransition extends AnimatedComponent {
}
}
}
}
/// Animates the s
ize of a
widget.
/// Animates the s
cale of transformed
widget.
class
ScaleTransition
extends
AnimatedComponent
{
class
ScaleTransition
extends
AnimatedComponent
{
ScaleTransition
({
ScaleTransition
({
Key
key
,
Key
key
,
...
@@ -171,6 +171,43 @@ class RotationTransition extends AnimatedComponent {
...
@@ -171,6 +171,43 @@ class RotationTransition extends AnimatedComponent {
}
}
}
}
/// Animates a widget's width or height.
class
SizeTransition
extends
AnimatedComponent
{
SizeTransition
({
Key
key
,
this
.
axis
:
Axis
.
vertical
,
Animation
<
double
>
sizeFactor
,
this
.
alignment
:
const
FractionalOffset
(
0.5
,
0.5
),
this
.
child
})
:
sizeFactor
=
sizeFactor
,
super
(
key:
key
,
animation:
sizeFactor
)
{
assert
(
axis
!=
null
);
}
/// [Axis.horizontal] if [sizeFactor] modifies the width, otherwise [Axis.vertical].
final
Axis
axis
;
/// The animation that controls the (clipped) size of the child. If the current value
/// of sizeFactor is v then the width or height of the widget will be its intrinsic
/// width or height multiplied by v.
final
Animation
<
double
>
sizeFactor
;
/// How to align the child. See the [Align] widget.
final
FractionalOffset
alignment
;
final
Widget
child
;
Widget
build
(
BuildContext
context
)
{
return
new
ClipRect
(
child:
new
Align
(
alignment:
alignment
,
heightFactor:
axis
==
Axis
.
vertical
?
sizeFactor
.
value
:
null
,
widthFactor:
axis
==
Axis
.
horizontal
?
sizeFactor
.
value
:
null
,
child:
child
)
);
}
}
/// Animates the opacity of a widget.
/// Animates the opacity of a widget.
class
FadeTransition
extends
AnimatedComponent
{
class
FadeTransition
extends
AnimatedComponent
{
FadeTransition
({
FadeTransition
({
...
...
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